package main

import (
    "bytes"
	. "code.google.com/p/go.crypto/ssh"
	"fmt"
)

func main() {
	config := &ClientConfig{
		User: "root",
		Auth: []AuthMethod{
			Password("123456"),
		},
	}
	client, err := Dial("tcp", "x.x.x.x:22", config)
	if err != nil {
		panic("Failed to dial: " + err.Error())
	}

	// Each ClientConn can support multiple interactive sessions,
	// represented by a Session.
	session, err := client.NewSession()
	if err != nil {
		panic("Failed to create session: " + err.Error())
	}
	defer session.Close()

	// Once a Session is created, you can execute a single command on
	// the remote side using the Run method.
	var b bytes.Buffer
	session.Stdout = &b
	if err := session.Run("pwd"); err != nil {
		panic("Failed to run: " + err.Error())
	}
	fmt.Println(b.String())


}
